package cn.elwy.rcp.ui.handler;

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.core.commands.IHandlerListener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.handlers.HandlerUtil;

import cn.elwy.rcp.ui.wizard.BaseWizard;
import cn.elwy.rcp.ui.wizard.BaseWizardDialog;

public class OpenWizardHandler implements IHandler {

  private BaseWizard wizard;

  @Override
  public void addHandlerListener(IHandlerListener handlerListener) {
  }

  @Override
  public void dispose() {
  }

  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {
    Shell activeShell = HandlerUtil.getActiveShell(event);
    BaseWizardDialog dialog = new BaseWizardDialog(activeShell, wizard, "BaseWizardDialog");
    return dialog.open();
  }

  @Override
  public boolean isEnabled() {
    return true;
  }

  @Override
  public boolean isHandled() {
    return true;
  }

  @Override
  public void removeHandlerListener(IHandlerListener handlerListener) {

  }

  public BaseWizard getWizard() {
    return wizard;
  }

  public void setWizard(BaseWizard wizard) {
    this.wizard = wizard;
  }

}
